<!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
<stack>
<name>in</name>
<id>-1</id>
<cardCount>1</cardCount>
<cardID>2817</cardID>
<listID>3713</listID>
<cantModify><false /></cantModify>
<cantDelete><false /></cantDelete>
<cantAbort><false /></cantAbort>
<cardSize>
<width>512</width>
<height>342</height>
</cardSize>
<script>-- PrintTheScripts-- ©1991 Richard Crispin. All Rights Reserved.-- May be freely used and given away but not sold alone or-- as part of a collection without the author's written permission.-- Search the current stack for all of the Handler/Function scripts, catalogues them-- and outputs the catalogue and the scripts."-- Global PrintScriptSettings-- Item 1: the number of scripts per page-- Item 2: the the Name of the Stack-- Item 3: the name of the current background-- Item 4: The name of the OutPut File-- Item 5: the name of the container (field or button)-- Item 6: True or false for Print and put in text file-- Item 7: Onhandler will be true or false-- Item 8: FunctionHandler will be true or false-- Item 9: the Name of the script that is returned-- Item 10: the length of outscript-- Item 11: the number of the script-- Item 12: the print header-- Item 13: DoStack-- Item 14: Number of backgrounds and True or False for each background-- Item 15 to Item 15 + number of backgrounds:-- True and false for Background Fields and Buttons for each background---- Global theScript-- contains the currently active script---- Global thePrintIndex-- contains the index for all of the handles etc. being printed---- Global theOutputFile-- This is where the output is stored. This is either printed or-- written to a file or both-- Global thePrintLog-- This contains all the messages produced by the printing process-- It is saved to a file at the end so the process can be checked-- Global theGlobals-- This contains a list of all the global variables with the handlers/functions-- that have these declared in it. If possible I may add a part where the-- variable is actually used or not in the handler/function.-- PrintTheScripts-- The main purpose of this handler is to fake a large dialog box using-- fields and buttons. This lets the user pick what to print in the output-- Once everything has been selected then NowPrintTheScripts actually does-- the work.On PrintTheScripts Skipglobal PrintScriptSettings,theScript,thePrintIndex,theOutputFile,thePrintLog,theGlobalsif skip is "?" thenanswer "PrintTheScripts"&return&"Search the current stack for all of the Handler/Function scripts, catalogue them and output the catalogue and the scripts."exit PrintTheScriptselse if skip is "!" thenanswer "PrintTheScripts"&return&"©1991 Richard Crispin. All Rights Reserved."&return&¬"May be freely used and given away but not sold alone or as part of a collection without the author's written permission."exit PrintTheScriptselse if skip is empty then put false into skipset cursor to busyPut "Setting up for printing scripts. Please wait."set lockscreen to trueput 0 into item 11 of PrintScriptSettingsput empty into theScriptput empty into thePrintIndexput empty into theOutputFileput empty into thePrintLogput empty into theGlobalsput the name of this stack into stacknameif skip thenNowPrintTheScriptselse-- set up and display the pseudo dialogue boxput "2,,,,,false true,false,false,,,0,true," into PrintScriptSettingsput stackname into item 2 of printscriptsettingsput the number of card fields into OriginalNumFieldsput the number of card buttons into OriginalNumButsdomenu "New Field"put the number of card fields into nnput the rectangle of the card window into crectput the left of the card window into clput the top of the card window into ctsubtract cl from item 1 of crectsubtract cl from item 3 of crectsubtract ct from item 2 of crectsubtract ct from item 4 of crectset the rectangle of card field nn to crectput item 3 of the rectangle of card field nn into rrrput item 4 of the rectangle of card field nn into bbbset the textfont of card field nn to "Courier"set the textsize of card field nn to "12"set the textheight of card field nn to "14"put "For the"&&stackname into line 1 of card field nnput "Stacks per page = 2" into line 3 of card field nnput 0 into item 1 of butrectput 3*14 into item 2 of butrectput (rrr/2)-5 into item 3 of butrectput 4*14 into item 4 of butrectDoSetUpButtons "Output to Printer",butrectput (rrr/2)+5 into item 1 of butrectput rrr into item 3 of butrectDoSetUpButtons "Output to File",butrectput "Click on the items to process:" into line 6 of card field nnput 0 into item 1 of butrectput (5*14)+2 into item 2 of butrectput (6*14)+2 into item 4 of butrectDoSetUpButtons "Print Stack Script",Butrectrepeat with i = 1 to the number of backgroundsput the name of background i into bnameadd 28 to item 2 of butrectadd 28 to item 4 of butrectDoSetUpButtons BName,ButRectput butrect into bfrectadd 20 to item 1 of bfrectadd 14 to item 2 of bfrectadd 14 to item 4 of bfrectput (item 1 of bfrect)+150 into item 3 of bfrectDOSetUpButtons "Background Fields",bfrectput bfrect into bbrectput (item 3 of bfrect)+20 into item 1 of bbrectput (item 1 of bbrect)+150 into item 3 of bbrectDOSetUpButtons "Background Buttons",bbrectend repeatput rrr into item 3 of brput bbb into item 4 of brput rrr-150 into item 1 of brput bbb-20 into item 2 of brDoSetUpButtons "Done Print Setup",brput the number of card buttons into bbset the style of card button bb to roundrectset the textstyle of card button bb to "Bold"set the hilite of card button bb to falseput "on mouseup"&return&"GetPrintScriptsSetup"&&originalnumfields&","&originalnumbuts&return&"DeleteExtras"&&originalnumfields&","&originalnumbuts&return&"NowPrintTheScripts"&return&"end mouseup" into bscriptset the script of card button bb to bscriptchoose browse toolput the time && the date && "Script for the"&&stackname&return into item 12 of PrintScriptSettingsset lockscreen to falseput emptyHide Messageselect the last word of line 3 of card field nnend ifend PrintTheScriptson NowPrintTheScriptsglobal PrintScriptSettings,theScript,thePrintIndex,theOutputFile,thePrintLog,theGlobalsput word 1 of item 6 of PrintScriptSettings into ToPrintput word 2 of item 6 of PrintScriptSettings into ToFileput empty into item 3 of PrintScriptSettingsif ToFile thenput item 2 of printscriptsettings into fnamedelete word 1 of fnamedelete char 1 of fnamedelete the last char of fnameput ".Scripts" after fnameask file "File to put scripts into" with fnameif it is empty thenanswer "No file specified. Halting Print"exit NowPrintTheScriptsend ifput it into fnameput fname into item 4 of PrintScriptSettingsLogMsg "Saving output to the file '"&fname&"'."open file fnameend ifif item 13 of PrintScriptSettings Thenput the script of this stack into theScriptif theScript is not empty thenput "Stack" into item 5 of PrintScriptSettingsProcessScript "The Stack Script"elseLogMsg "There is no stack script."end ifend ifpush cardset lockmessages to trueset lockrecent to trueput word 1 of item 14 of PrintScriptSettings into NBKGSrepeat with i= 1 to NBKGSgo to background iput the name of background i into item 3 of PrintScriptSettingsput "Background" into item 5 of PrintScriptSettingsput empty into item 7 of PrintScriptSettingsput empty into item 8 of PrintScriptSettingsLogMsg "Processing Background"&&i&"("&item 3 of PrintScriptSettings&")."if word 1+i of item 14 of PrintScriptSettings thenput the script of background i into theScriptif theScript is not empty thenProcessScript item 3 of PrintScriptSettingselseLogMsg "There is no script for background"&&i&"("&item 3 of PrintScriptSettings&")."end ifend ifif word 1 of item 14+i of PrintScriptSettings thenput 0 into nfLogMsg "Processing Fields"repeat with f=1 to the number of background fieldsput the script of background field f into theScriptif theScript is not empty thenput the name of background field f into item 5 of PrintScriptSettingsadd 1 to nfProcessScript item 5 of PrintScriptSettingsend ifend repeatif nf is 0 then LogMsg "There were no field scripts."end ifif word 2 of item 14+i of PrintScriptSettings thenput 0 into nfLogMsg "Processing Buttons"repeat with f=1 to the number of background buttonsput the script of background button f into theScriptif theScript is not empty thenput the name of background button f into item 5 of PrintScriptSettingsadd 1 to nfProcessSCript item 5 of printScriptSettingsend ifend repeatif nf is 0 then LogMsg "There were no button scripts."end ifend repeatif the length of theOutputFile > 1 thenif tofile thenwrite theOutputFile to file fname at endend ifif toprint thenprint theOutputFIleend ifput empty into theOutputFIleend ifLogMsg "Formating the Global Variable Indexes for output."-- set up a copy of the index without the " ." strings-- set up the Handler and Function sub-indexesput empty into HandlerIndexput empty into FunctionIndexput thePrintIndex into TempPIndexrepeat with i=1 to the number of lines in TempPIndexset cursor to busyput line i of TempPIndex into tLine-- if SeparateIndexes thenif word 2 of tLine is "Handler" thenput tLine&return after HandlerIndexdelete word 2 of the last line of HandlerIndexelse if word 2 of tLine is "Function" thenput tLine&return after FunctionIndexdelete word 2 of the last line of FunctionIndexend if-- end ifput the last word of tLine into NNdelete the last word of tLinerepeat while the last char of tLine is in " ."delete the last char of tLineend repeatput tLine&&NN into line i of TempPindexend repeat-- Setup a header for the top of pageput (numtochar(12))&(item 12 of PrintScriptSettings)&return into SubHead-- Set up the global index by variable nameput theGlobals into tempput temp into temp2sort tempput empty into theGlobalsput " -" into srepeat with L = 1 to the number of lines in Tempset cursor to busyif line L of temp is empty then next repeatput line L of temp into CGlobalput return&(item 1 of CGlobal)&return after theGlobalsrepeat with i=2 to the number of items in CGlobalput item i of CGlobal into CGiput line (the last word of CGi) of TempPindex into ientryput the last word of ientry into Ndelete the last word of ientryput s&(char 1 of CGi)&&(N&&ientry)&return after theGlobalsend repeatend repeat--set up Global index by scriptput empty into temprepeat with L=1 to the number of lines in temp2set cursor to busyput line L of temp2 into instringif instring is empty then next repeatput item 1 of instring into VNamerepeat with i=2 to the number of items in instringput char 1 of item i of instring into cput the last word of item i of instring into nif line n of temp is empty thenput line n of TempPindex&","&&c&vname into line n of tempelseput ","&&c&vname after the last item of line n of tempend ifend repeatend repeatput empty into TempPIndexput empty into temp2repeat with L = 1 to the number of lines in tempset cursor to busyput line L of temp into instringif instring is empty then next repeatput return&(item 1 of instring)&return after temp2delete item 1 of instringput s&instring&return after temp2end repeatput temp2 into tempput subHead&"LIST OF GLOBAL VARIABLES BY HANDLER/FUNCTION"&return&return&¬"* = Global is defined but may not be used in the script."&return&return¬before tempput return&temp after theGlobalsput subhead&"LIST OF GLOBAL VARIABLES BY VARIABLE NAME"&return&return&¬"* = Global is defined but may not be used in the script."&return before theGlobalsLogMsg "Formating the Script Indexes for Output."put thePrintIndex into tempsort tempsort HandlerIndexsort FunctionIndexput subhead&("TABLE OF CONTENTS FOR"&&item 2 of printscriptsettings)&return&return before thePrintIndexput subHead&("TABLE OF CONTENTS FOR"&&item 2 of printscriptsettings)&&"SORTED BY NAME"&return&return before Tempput thePrintIndex&return&temp into thePrintIndexput subhead&"LIST OF HANDLERS"&return&return&HANDLERINDEX after thePrintIndexput subhead&"LIST OF FUNCTIONS"&return&return&FUNCTIONINDEX after thePrintIndexput thePrintIndex&theGlobals&return into tempif tofile thenclose file fnameopen file fnameread from file fname until endclose file fnameput it into temp2open file fnamewrite temp to file fnamewrite temp2 to file fnameclose file fnameend ifif toprint thenprint tempend ifput item 2 of PrintScriptSettings into LogFileNamedelete word 1 of LogFileNamedelete char 1 of LogFileNamedelete last char of LogFileNameask file "Where to put the log file" with LogFileName&".Print Script Log"if it is empty thenLogmsg "Log file not savedelseput it into LogFileNameLogMsg "Outputing log to '"&&LogFileName&&"'."open file LogFileNamewrite thePrintLog to file LogFileNameclose file LogFileNameend ifpop cardput emptyhide messageput empty into theGlobalsput empty into thePrintIndexput empty into thePrintLogput empty into theScriptif tofile thenanswer "The file should be converted to COURIER 10 with a Left margin of .75in and a right margin of .5in."end ifset lockmessages to falseset lockrecent to falseend NowPrintTheScriptsOn ProcessScript infomessageglobal PrintScriptSettings,theScript,thePrintIndex,theOutputFileif infomessage is not empty then LogMsg "Processing"&&infomessageput " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ." into dotlineput dotline&&dotline into dotlineput word 1 of item 6 of PrintScriptSettings into ToPrintput word 2 of item 6 of PrintScriptSettings into ToFileif tofile then put item 4 of printscriptsettings into fnameput item 5 of PrintScriptSettings into kkdelete word 1 of kkput item 3 of PrintScriptSettings&" " before kkif kk is " " then put "Stack" into KKrepeat while theScript is not emptyset cursor to busyput separatescript()&return&return into tempCheckGlobals tempput empty into SWhatif item 7 of PrintScriptSettings then put "Handler" into SWhatif item 8 of PrintScriptSettings then put "Function" into SWhatput (item 9 of printscriptsettings)&&SWhat&&"("&kk&")" into subheadif trunc(length(subhead)/2)*2 <> length(subhead) then put " " after subheadput dotline after subheadset the numberformat to "0000"put (char 1 to 80 of subhead)&&(0+item 11 of printscriptsettings) into subheadset numberformat to "0"put (item 12 of printscriptsettings)&return&subhead&return before tempput subhead&RETURN after thePrintIndexif (the number of lines in theOutputFIle + the number of lines in temp) > 65 thenif tofile thenwrite theOutputFIle to file fname at endend ifif toprint thenprint theOutputFIleend ifput numtochar(12) into theOutputFIleend ifput temp after theOutputFIleif the number of lines in theOutputFIle < 65 thenput return&return&return after theOutputFIleend ifend repeatend ProcessScriptOn DoSetUpButtons BName,ButRectset cursor to busydomenu "New Button"put the number of card buttons into bbset the name of card button bb to BNameset the textfont of card button bb to "Courier"set the textsize of card button bb to "12"set the rect of card button bb to butrectset the style of card button bb to "checkBox"set the autohilite of card button bb to trueset the hilite of card button bb to trueend DoSetUpButtonsOn DeleteExtras NumFields,NumButsset cursor to watchset lockscreen to trueput (the number of card buttons) - (numbuts) into numDelbuttonsrepeat numDelbuttonsselect card button (Numbuts+1)domenu "Clear button"end repeatput (the number of card fields) - (numfields) into numDelFieldsrepeat numDelFieldsselect card field (NumFields+1)domenu "Clear Field"end repeatunlock screenchoose browse toolend DeleteExtrasOn GetPrintScriptsSetup NumFields,NumButsglobal PrintScriptSettings,theOutputFileLogMsg "Retrieving script print settings"set cursor to busyput the number of card fields into NCFput the number of card buttons into NCBput the hilite of card button "Print Stack Script" into item 13 of PrintScriptSettingsput (the hilite of card button "Output to printer")&&(the hilite of card button "Output to File") into item 6 of PrintScriptSettingsput ((the number of card buttons) - (NumButs + 4))/3 into dobsput empty into doFsBsput NumButs+4 into irepeat while i < NCB-1set cursor to busyput " "&the hilite of card button i after dobsput i+1 into fnput i+2 into bnput (the hilite of card button fn)&&(the hilite of card button bn)&"," after doFsBsadd 3 to iend repeatput dobs into item 14 of PrintScriptSettingsdelete the last char of doFsBsput doFsBs into item 15 of PrintScriptSettingsput the last word of line 3 of card field NCF into item 1 of PrintScriptSettingsEnd GetPrintScriptsSetupFunction SeparateScriptglobal PrintScriptSettings,theScript,theOutputFileput return&"on " into OnHandlerput return&"Function " into FunctionHandlerput return&"end " into EndHandlerif the first char of theScript is not return then put return before theScriptput offset(OnHandler,theScript) into HandlerStartput offset(FunctionHandler,theScript) into FunctionStartif handlerstart=0 and FunctionStart=0 thenput false into IsHandlerput false into IsFunctionput theScript into outscriptput empty into theScriptput " No Handler/Function" into theNameLogMsg "Script not empty but NO Handler/Function"&&item 5 of printscriptsettingsput 0 into selse if handlerStart>0 and FunctionStart=0 thenput true into IsHandlerput false into IsFunctionput HandlerStart+1 into selse if handlerStart=0 and FunctionStart>0 thenput false into IsHandlerput true into IsFunctionput FunctionStart+1 into selse if HandlerStart < FunctionStart thenput true into IsHandlerput false Into IsFunctionput HandlerStart+1 into selseput false into IsHandlerput true into IsFunctionput FunctionStart+1 into send ifadd 1 to item 11 of PrintScriptSettingsif s>0 thenput char 1 to s-1 of theScript into OutScriptdelete char 1 to s-1 of theScriptput word 2 of line 1 of theScript into theNameLogMsg "Processing Number"&&item 11 of PrintScriptSettings&&"("&theName&")."put offset(EndHandler,theScript) into eput char 1 to e of theScript after OutScriptdelete char 1 to e of theScriptput word 2 of line 1 of theScript into tif t <> theName thenanswer "ERROR"&return&"The function or handler '"&theName&"' does not appear to have an end."LogMsg "The function or handler '"&theName&"' does not appear to have an end."end ifput line 1 of theScript after OutScriptDelete line 1 of theScriptend ifput Ishandler into item 7 of PrintScriptSettingsput IsFunction into item 8 of PrintScriptSettingsput theName into item 9 of PrintScriptSettingsput the length of outscript into Item 10 of PrintScriptSettingsreturn OutScriptend SeparateScriptOn CheckGlobals InputScriptGlobal theGlobals,PrintScriptSettingsif offset("Global",InputScript) = 0 thenput " NO GLOBALS" after msgexit CheckGlobalsend ifput item 11 of PrintScriptSettings into SNumput item 9 of PrintScriptSettings into SNameput item 5 of PrintScriptSettings into CNameput item 3 of PrintScriptSettings into BNameput the numberformat into nfmtset the numberformat to "0000"put False Into IsGlobalsput the number of lines in InputScript into NSLinesrepeat with L= 1 to NSLinesset cursor to busyif word 1 of line L of InputScript is "Global" thenput true into IsGlobalsLogMsg "Processing globals for"&&snum&&Sname&&CName&&Bnameput line L of InputScript into newglobalsdelete word 1 of newglobalsrepeat until char 1 of newglobals is not " "delete char 1 of newglobalsend repeatrepeat until last char of newglobals is not " "delete last char of newglobalsend repeatrepeat with i = 1 to the number of items in newglobalsset cursor to busyput item i of newglobals into CurrentGlobalput 0 into GlobalLineif CurrentGlobal is in theGlobals thenrepeat with g=1 to the number of lines in theGlobalsif currentGlobal = word 1 of item 1 of line g of theGlobals thenput g into GlobalLineexit repeatend ifend repeatend ifif GlobalLine is 0 thenput return&CurrentGlobal after theGlobalsput the number of lines in theGlobals into GlobalLineend ifif CurrentGlobal is not in line L+1 to NSLines of InputScript then put "*" into celse put " " into cput ","&c&&SNum after the last item of line globalLine of theGlobalsend repeatelseif IsGlobals thenput false into IsGlobalsexit repeatend ifend ifend repeatset the numberformat to nfmtend CheckGlobalson LogMsg MMGlobal thePrintLogput the long time&&the date&&mm&return after thePrintLogput mmend LogMsg</script>